<?php
session_start();
if((isset($_SESSION['login'])) AND (isset($_SESSION['lastname']))) {
$nomami = $_SESSION['lastname'];
$nom = $_SESSION['myname'];
$id = $_SESSION['myid'];
include("config.php");
dbconnect();
$db = mysql_query("SELECT *  FROM `gb_".$nomami."_friends` WHERE `friendid` = ".$id);
$data = mysql_fetch_assoc($db);
if(empty($data['friendid'])) {
mysql_query("INSERT INTO `gb_".$nomami."_friends` (`id`, `friendid`, `status`, `name`) VALUES (NULL, '".$id."', '0', '".$nom."');");
echo(mysql_error());
mysql_close();
echo("Requête d'ami envoyée");
}
else {
echo("Requête déjà envoyée");
mysql_close();
}
}
?>